<template>
  <el-container class="main_con">
    <ufrom @submit="saveData" ref="ufrom">
      <el-form size="medium" label-width="200px">
        <div class="setting_body_item">
          <div class="header">积分规划</div>
          <div class="conetnt edit_con">
            <div class="edit_content">
              <el-form-item label="一天分享次数"><el-input v-model="obj.daily_limit" style="width:240px;"></el-input></el-form-item>
              <el-form-item label="新用户分享获得积分"><el-input v-model="obj.share.new" style="width:240px;"></el-input></el-form-item>
              <el-form-item label="老用户分享获得积分"><el-input v-model="obj.share.old" style="width:240px;"></el-input></el-form-item>
            </div>
          </div>
        </div>
      </el-form>
    </ufrom>
  </el-container>
</template>

<script>
import {integralfind, editintegralshare} from '@/api/mall/setting';
export default {
  data() {
    return {
      isLoading: false,
      obj: {
        daily_limit: 0,
        share: {
          old: 0,
          new: 0
        }
      }
    };
  },
  components: {},
  mounted() {
    this.getConfig();
  },
  methods: {
    //获取站点配置数据
    getConfig(type) {
      this.isLoading = true;
      integralfind({})
        .then(res => {
          if (res.msg) {
            this.obj = res.msg;
          }
        })
        .catch(e => {
        });
    },
    //保存数据
    saveData() {
      let data = {
        daily_limit: this.obj.daily_limit,
        old: this.obj.share.old,
        new: this.obj.share.new
      };
      editintegralshare(data)
        .then(res => {
          this.$refs.ufrom.init()
          this.$message.success('修改成功');
          this.getConfig();

        })
        .catch(e => {
          this.$refs.ufrom.init()
        });

    }
  }
};
</script>

<style lang="scss" scoped>
//覆盖样式
.main_con .edit_con .edit_content {
  border-bottom: 0;
}


</style>
